'use strict';

const secondHand = document.querySelector('.second-hand');
const minuteHand = document.querySelector('.min-hand');
const hourHand = document.querySelector('.hour-hand');

function setDate() {
  // 获取当前时间
  const now = new Date();

  // 读秒
  const seconds = now.getSeconds();
  // 计算旋转角度
  const secondsDeg = (seconds / 60) * 360 + 90;
  // 设置秒针角度
  secondHand.style.transform = `rotate(${secondsDeg}deg)`;

  // 读分
  const minutes = now.getMinutes();
  const minutesDeg = (minutes / 60) * 360 + 90;
  minuteHand.style.transform = `rotate(${minutesDeg}deg)`;

  // 读时
  const hours = now.getHours();
  const hoursDeg = (hours / 12) * 360 + 90;
  hourHand.style.transform = `rotate(${hoursDeg}deg)`;
}

setInterval(setDate, 1000);
